package com.ak.gateway.runner;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

import com.ak.gateway.service.BlackListService;
import com.ak.gateway.service.RateLimitRuleService;
import com.ak.gateway.service.RouteEnhanceCacheService;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Vean
 */
@Slf4j
@RequiredArgsConstructor
public class RouteEnhanceRunner implements ApplicationRunner {

    private final RouteEnhanceCacheService cacheService;
    private final BlackListService blackListService;
    private final RateLimitRuleService rateLimitRuleService;

    @Override
    public void run(ApplicationArguments args) {
    	log.info("初始化网关规则数据");
        cacheService.saveAllBlackList(blackListService.findAll());
        cacheService.saveAllRateLimitRules(rateLimitRuleService.findAll());
        log.info("初始网关规则数据完毕");
    }
}
